package com.kurancy.domain;

import java.util.Collection;
import java.util.List;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

public class UserAuth implements UserDetails, Authentication {

	private static final long serialVersionUID = -6776625768588764940L;
	private String username;
	private List<GrantedAuthority> authorities;
	private KurancyUser kurancyUser;

	@Override
	public Collection<? extends GrantedAuthority> getAuthorities() {
		return authorities;
	}
	
	public void setAuthorities(List<GrantedAuthority> authorities) {
		this.authorities = authorities;
	}

	@Override
	public String getPassword() {
		return null;
	}

	@Override
	public String getUsername() {
		return username;
	}

	@Override
	public boolean isAccountNonExpired() {
		return false;
	}

	@Override
	public boolean isAccountNonLocked() {
		return false;
	}

	@Override
	public boolean isCredentialsNonExpired() {
		return false;
	}

	@Override
	public boolean isEnabled() {
		return true;
	}

	public KurancyUser getKurancyUser() {
		return kurancyUser;
	}

	public void setKurancyUser(KurancyUser kurancyUser) {
		this.kurancyUser = kurancyUser;
	}

	@Override
	public String getName() {
		return kurancyUser.getFirstName() + " " + kurancyUser.getLastName();
	}

	@Override
	public Object getCredentials() { 
		return null;
	}

	@Override
	public Object getDetails() {
		return null;
	}

	@Override
	public Object getPrincipal() {
		return kurancyUser.getFacebookUserId();
	}

	@Override
	public boolean isAuthenticated() {
		return kurancyUser != null;
	}

	@Override
	public void setAuthenticated(boolean isAuthenticated) throws IllegalArgumentException {}

}
